package com.ymh.controller;

import com.ymh.common.domain.ResultData;

import com.ymh.domain.OrderDTO;
import com.ymh.feign.OrderFeign;
import com.ymh.service.OrderService;
import java.math.BigDecimal;
import java.util.UUID;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author: 13590
 * @date: 2020/10/27 19:23
 * @description:
 */
@RestController
@Slf4j
public class OrderController implements OrderFeign {

  @Autowired
  private OrderService orderService;

  @Override
  @PostMapping("/create")
  public ResultData<OrderDTO> create(@RequestBody OrderDTO orderDTO) {
    log.info("create order:{}", orderDTO);
    orderDTO.setOrderNo(UUID.randomUUID().toString());
    orderDTO.setAmount(orderDTO.getPrice().multiply(new BigDecimal(orderDTO.getCount())));
    orderService.createOrder(orderDTO);
    return ResultData.success("create order success");
  }

  @GetMapping("/a/b/c")
  public String test(){
    return "OKabc";
  }


  @GetMapping("/a/b/d")
  public String test1(){
    return "OKabd";
  }
}
